@extends('layouts.admin')
@section('content')
    {{--错误信息--}}
    @if(count($errors)>0)
        <div class="mark">
            @if(is_object($errors))
                @foreach($errors->all() as $error)
                    <p>{{$error}}</p>
                @endforeach
            @else
                <p>{{$errors}}</p>
            @endif
        </div>
    @endif
	<table class="table table-hover">
		<tr class="active">

			<th width="210">品牌名称</th>
			<th>品牌LOGO</th>

			<th width="210">操作</th>
		</tr>
		@foreach($data as $v)
		<tr>
			<td>{{$v->_bname}}</td>
			<td>
				<img src="/{{$v->logo}}" alt="" style="max-width: 75px; max-height:75px;">
			</td>
			<td>
				<a href="{{url('admin/brand/'.$v->bid.'/edit')}}" class="btn btn-sm btn-warning">编辑</a>
				<a href="javascript:;" onclick="delbrand({{$v->bid}})" class="btn btn-sm btn-danger">删除</a>
                @if($v->pid == 0)
                    <a href="{{url('admin/brand/create/'.$v->bid)}}" class="btn btn-sm btn-primary">添加车系</a>
                @endif
			</td>
		</tr>
		@endforeach
	</table>
	{{--删除询问--}}
	<script type="text/javascript" src="{{asset('public/sytle/uploadify/jquery-1.8.2.min.js')}}"></script>
	<script type="text/javascript" src="{{asset('public/org/layer/layer.js')}}"></script>
	<script>
		function delbrand(bid) {
//            alert(1);
			layer.confirm('您确定要删除此品牌/车系吗？', {  //layer插件
				btn: ['确定','取消'] //按钮
			}, function(){  //确定时
//                alert(mid);
				$.post("{{url('admin/brand/')}}/"+bid,{'_method':'delete','_token':"{{csrf_token()}}"},function (data) {
//异步：【路径/+参数（资源路由DELETE|admin/carModel/{brand}）】，【参数：资源路由DELETE，CSRF保护措施】，【返回后启用的方法】
//                    alert(data.msg);
					if(data.status==0){
						location.href = location.href;//刷新当前页面
						layer.msg(data.msg, {icon: 6});//成功提示：layer插件
					}else{
						layer.msg(data.msg, {icon: 5});//成失败提示：layer插件
					}
				});
//                layer.msg('的确很重要', {icon: 1});
			}, function(){  //取消时

			});
		}

	</script>
@endsection





